package com.acme.task3;

public class Task3Arrays {
	public static void main(String[] args) {
		System.out.println(avg(getNaturalNumbers(10)));
	}
	
	/**
	 * prints first {@code n} numbers
	 * @param n
	 */
	public static void printNaturalNumbers(int n) {
		for (int i = 1; i <= n; i++) {
			System.out.println(i);
		}
	}
	
	/**
	 * prints "Число m кратно трем" for all {@code m<n} 
	 * and {@code m=0(mod3)}
	 * @param n
	 */
	public static void printNaturalNumbersMod3(int n) {
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0)
				System.out.println("Число " + i + " кратно трем");
		}
	}
	
	/**
	 * @param array
	 * @return average of array
	 */
	public static double avg(int[] array) {
		double res = 0.d;
		for (int i : array) {
			res += i;
		}
		return res / array.length;
	}
	
	/**
	 * Returns first {@code n} numbers
	 * @param n
	 * @return
	 */
	public static int[] getNaturalNumbers(int n) {
		int[] result = new int[n];
		for (int i = 1; i <= n; i++) {
			result[i - 1] = i;
		}
		return result;
	}
}
